<template>
  <web-view
    src="http://172.16.20.70:8088/wx-chat/index"
    update-title="false"
    @message="message"
  ></web-view>
</template>

<script setup>
const load = ref(false);
const src = ref("");
onLoad((options) => {
  uni.setNavigationBarTitle({
    title: "图片生成中",
  });
  src.value = `http://172.16.20.70:8088/wx-chat/index?shareId=${options.shareId}`;
  wx.showLoading({
    title: "生成图片中",
    mask: true,
    success: (result) => {},
    fail: () => {},
    complete: () => {},
  });
});

function message(e) {
  wx.setStorageSync("shareImage", e.detail.data[0]);
}
// function base64ToFilePath(base64data) {
//   //封装的base64转换成临时文件路径的函数
//   const base64 = base64data; //base64格式图片
//   const time = new Date().getTime();
//   const imgPath = wx.env.USER_DATA_PATH + "/" + time + "share_qrcode.png"; //去掉data:image/png;base64,如果图片字符串不含要清空的前缀,可以不执行下行代码.
//   const imageData = base64.replace(/^data:image\/\w+;base64,/, "");
//   const file = wx.getFileSystemManager();
//   file.writeFileSync(imgPath, imageData, "base64");

//   wx.showShareImageMenu({
//     //分享给朋友
//     path: imgPath,
//     success: (res) => {
//       console.log("分享成功：", res);
//     },
//     fail: (err) => {
//       console.log("分享取消：", err);
//     },
//     complete() {
//       wx.navigateBack({
//         delta: 1,
//       });
//     },
//   });
// }
</script>
<style lang="scss" scoped></style>
